// 2025/4/19
// 小葱的01串

#include <iostream>
using namespace std;

int main() {
    int n; cin >> n;
    string str; cin >> str;
    int tarOne = 0, curOne = 0;
    for(int i = 0; i < n; i++)
    {
        if(str[i] == '1')
        {
            tarOne++;
            if(i < n / 2)
                curOne++;
        }
    }
    if(tarOne % 2 == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    tarOne /= 2;

    int ans = 0, left = 0, right = n / 2 - 1;
    for(left = 0; left < n; left++)
    {
        right = (right + 1) % n;
        if(str[left] == '1')
            curOne--;
        if(str[right] == '1')
            curOne++;

        if(curOne == tarOne)
            ans++;
    }
    cout << ans << endl;
}
// 64 位输出请用 printf("%lld")